<%--
  @author Tharanga Punchihewa
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>

<script type="text/javascript ">
    $(document).ready(function() {
        $('.organization-list').dataTable({
            "sPaginationType": "full_numbers",
            "bDestroy": true,
            "oLanguage": {
                "sZeroRecords": $('#no-record').val(),
                "sLengthMenu": $('#display').val() + " _MENU_ " + $('#records').val(),
                "sSearch": $('#search').val(),
                "sInfo": $('#showing').val() + " _START_ " + $('#to').val() + " _END_ " + $('#of').val() + " _TOTAL_ " + $('#entries').val(),
                "sInfoEmpty": $('#no-record').val(),
                "oPaginate": {
                    "sFirst": $('#first').val(),
                    "sLast": $('#last').val(),
                    "sNext": $('#next').val(),
                    "sPrevious": $('#previous').val()
                }
            }
        });
    });
</script>
<div id="land-registration-module-home-title" class="module-home-title">
    <s:a href="landInterests.do"><img src="${pageContext.request.contextPath}/images/land-reg.png"
                                             alt="Land Registration"><span><s:label
            value="Land Interests"/></span></s:a>
    <span class="module-title-breaker"> > </span>
    <s:if test="pageMode==0">
        <s:a href="#"><img src="${pageContext.request.contextPath}/images/modify-form.png"
                           alt="Land Registration"><span><s:label
                value="%{getText('edit_organization.label')}"/></span></s:a>
    </s:if>
    <s:elseif test="pageMode==1">
        <s:a href="#"><img src="${pageContext.request.contextPath}/images/registration-form.png"
                           alt="Land Registration"><span><s:label
                value="%{getText('active_inactive_organization.label')}"/></span></s:a>
    </s:elseif>
    <s:elseif test="pageMode==2">
        <s:a href="#"><img src="${pageContext.request.contextPath}/images/accept.png"
                           alt="Land Registration"><span><s:label
                value="%{getText('register_organization.label')}"/></span></s:a>

    </s:elseif>
    <s:elseif test="pageMode==3">
        <s:a href="#"><img src="${pageContext.request.contextPath}/images/people.png"
                           alt="Land Registration"><span><s:label
                value="%{getText('create_orpii_user.label')}"/></span></s:a>

    </s:elseif>
    <s:elseif test="pageMode==4">
        <s:a href="#"><img src="${pageContext.request.contextPath}/images/people-image-2.png"
                           alt="Land Registration"><span><s:label
                value="%{getText('create_ur-mgoi_user.label')}"/></span></s:a>

    </s:elseif>
    <s:elseif test="pageMode==5">
        <s:a href="#"><img src="${pageContext.request.contextPath}/images/update-user.png"
                           alt="Land Registration"><span><s:label
                value="%{getText('edit_users.label')}"/></span></s:a>

    </s:elseif>
    <s:elseif test="pageMode==6">
        <s:a href="#"><img src="${pageContext.request.contextPath}/images/active-user-icon.png"
                           alt="Land Registration"><span><s:label
                value="%{getText('active_inactive_users.label')}"/></span></s:a>

    </s:elseif>
    <s:elseif test="pageMode==7">
        <s:a href="#"><img src="${pageContext.request.contextPath}/images/mail.png"
                           alt="Land Registration"><span><s:label
                value="%{getText('send_latter.label')}"/></span></s:a>

    </s:elseif>
    <s:else>
        <s:a href="#"><img src="${pageContext.request.contextPath}/images/company-profile.png"
                           alt="Land Registration"><span><s:label
                value="%{getText('add_organization.label')}"/></span></s:a>
    </s:else>
</div>

<s:if test="pageMode==0">
    <div class="page-title">
        <h2><s:label value="%{getText('edit_organization.label')}"/></h2>
    </div>
</s:if>
<s:elseif test="pageMode==1">
    <div class="page-title">
        <h2><s:label value="%{getText('active_inactive_organization.label')}"/></h2>
    </div>
</s:elseif>
<s:elseif test="pageMode==2">
    <div class="page-title">
        <h2><s:label value="%{getText('register_organization.label')}"/></h2>
    </div>
</s:elseif>
<s:elseif test="pageMode==3">
    <div class="page-title">
        <h2><s:label value="%{getText('create_orpii_user.label')}"/></h2>
    </div>
</s:elseif>
<s:elseif test="pageMode==4">
    <div class="page-title">
        <h2><s:label value="%{getText('create_ur-mgoi_user.label')}"/></h2>
    </div>
</s:elseif>
<s:elseif test="pageMode==5">
    <div class="page-title">
        <h2><s:label value="%{getText('edit_users.label')}"/></h2>
    </div>
</s:elseif>
<s:elseif test="pageMode==6">
    <div class="page-title">
        <h2><s:label value="%{getText('active_inactive_users.label')}"/></h2>
    </div>
</s:elseif>
<s:elseif test="pageMode==7">
    <div class="page-title">
        <h2><s:label value="%{getText('send_latter.label')}"/></h2>
    </div>
</s:elseif>
<s:if test="pageMode==9">
    <s:form>
        <div align="right">
            <tr>
                <td><s:submit value="%{getText('add_new.label')}" action="populateInitAddOrganization"></s:submit></td>
            </tr>
        </div>
    </s:form>
</s:if>
<table class="width-100 margin-10-auto table organization-list">
    <thead>
    <tr class="center-align table-header">
        <th><s:label value="%{getText('reference_no.label')}"/></th>
        <th><s:label value="%{getText('Organization Name')}"/></th>
        <s:if test="pageMode ==0 || pageMode ==1">
            <th><s:label value="%{getText('status.label')}"/></th>
        </s:if>
        <s:if test="pageMode==0">
            <th><s:label value="%{getText('due_date.label')}"/></th>
            <th><s:label value="%{getText('edit.label')}"/></th>
        </s:if>
        <s:elseif test="pageMode==1">
            <th><s:label value="%{getText('active.label')}"/></th>
        </s:elseif>
        <s:elseif test="pageMode==2">
            <th><s:label value="%{getText('register.label')}"/></th>
        </s:elseif>
        <s:elseif test="pageMode==3">
            <th><s:label value="%{getText('create_orpii_user.label')}"/></th>
        </s:elseif>
        <s:elseif test="pageMode==4">
            <th><s:label value="%{getText('create_ur-mgoi_user.label')}"/></th>
        </s:elseif>
        <s:elseif test="pageMode==5">
            <th><s:label value="%{getText('edit.label')}"/></th>
        </s:elseif>
        <s:elseif test="pageMode==6">
            <th><s:label value="%{getText('active.label')}"/></th>
        </s:elseif>
        <s:elseif test="pageMode==7">
            <th><s:label value="%{getText('due_date.label')}"/></th>
            <th><s:label value="%{getText('send_latter.label')}"/></th>
        </s:elseif>
        <s:elseif test="pageMode==9">
            <th><s:label value="Add Organization"/></th>
        </s:elseif>
    </tr>
    </thead>
    <tbody>
    <s:iterator status="status1" value="organizationsList">
        <tr>
        <td class="center-align"><s:property value="id"/></td>
        <td class="left-align">
            <s:if test="language=='si'">
                <s:property value="organizationNameSi"/>
            </s:if> <s:elseif test="language=='en'">
            <s:property value="organizationNameEn"/>
        </s:elseif><s:elseif test="language=='ta'">
            <s:property value="organizationNameTa"/>
        </s:elseif>
        </td>
        <s:if test="pageMode ==0 || pageMode ==1">
            <td class="center-align">
                <s:property value="type"/>
            </td>
        </s:if>
        <s:if test="pageMode==0">
            <td class="center-align">
                <s:if test="type.ordinal()== 1">
                    <s:property value="dueDate"/>
                </s:if>
                <s:elseif test="type.ordinal()== 0">
                    <s:label value="-"/>
                </s:elseif>
            </td>
            <td class="center-align">
                <s:if test="status.ordinal()== 0">
                    <s:url id="initEditOrganizationInfo" action="initEditOrganizationInfo">
                        <s:param name="organizationId" value="id"/>
                        <s:param name="editMode" value="1"/>
                    </s:url>
                    <s:a href="%{initEditOrganizationInfo}">
                        <img src="<s:url value='/images/modify-form.png'/>" border="none" width="25"
                             height="25" title="Edit"/>
                    </s:a>
                </s:if>
            </td>
        </s:if>
        <s:elseif test="pageMode==1">
            <td class="center-align">
                <s:if test="status.ordinal()==1">
                    <s:url id="activeOrganization" action="activeOrganization">
                        <s:param name="organizationId" value="id"/>
                    </s:url>
                    <s:a href="%{activeOrganization}">
                        <img src="<s:url value='/images/approve.png'/>" class="image-icon" title="Active"/>
                    </s:a>
                </s:if>
                <s:if test="status.ordinal()== 0">
                    <s:url id="inactiveOrganization" action="inactiveOrganization">
                        <s:param name="organizationId" value="id"/>
                    </s:url>
                    <s:a href="%{inactiveOrganization}">
                        <img src="<s:url value='/images/reject.png'/>" class="image-icon" title="Inactive"/>
                    </s:a>
                </s:if>

            </td>
        </s:elseif>
        <s:elseif test="pageMode==2">
            <td class="center-align">
                <s:if test="status.ordinal()== 0">
                    <s:url id="initRegisterOrganization" action="initRegisterOrganization">
                        <s:param name="organizationId" value="id"/>
                    </s:url>
                    <s:a href="%{initRegisterOrganization}">
                        <img src="<s:url value='/images/icon_register.jpg'/>" border="none" width="25"
                             height="25" title="Register"/>
                    </s:a>
                </s:if>
            </td>
        </s:elseif>
        <s:elseif test="pageMode==3">
            <td class="center-align">
                <s:url id="initCreateORPIIUsers" action="initCreateORPIIUsers">
                    <s:param name="organizationId" value="id"/>
                </s:url>
                <s:a href="%{initCreateORPIIUsers}">
                    <img src="<s:url value='/images/people.png'/>" border="none" class="image-icon" title="Create"/>
                </s:a>
            </td>
        </s:elseif>
        <s:elseif test="pageMode==4">
            <td class="center-align">
                <s:url id="urmgoiUserList" action="urmgoiUserList">
                    <s:param name="organizationId" value="id"/>
                </s:url>
                <s:a href="%{urmgoiUserList}">
                    <img src="<s:url value='/images/people-image-2.png'/>" class="image-icon" title="Create"/>
                </s:a>
            </td>
        </s:elseif>
        <s:elseif test="pageMode==5">
            <td class="center-align">
                <s:url id="organizationUserManagementList" action="organizationUserManagementList">
                    <s:param name="organizationId" value="id"/>
                    <s:param name="pageMode" value="5"/>
                </s:url>
                <s:a href="%{organizationUserManagementList}">
                    <img src="<s:url value='/images/update-user.png'/>" border="none" class="image-icon"/>
                </s:a>
            </td>
        </s:elseif>
        <s:elseif test="pageMode==6">
            <td class="center-align">
                <s:url id="organizationUserManagementList" action="organizationUserManagementList">
                    <s:param name="organizationId" value="id"/>
                    <s:param name="pageMode" value="6"/>
                </s:url>
                <s:a href="%{organizationUserManagementList}">
                    <img src="<s:url value='/images/update-user.png'/>" border="none" class="image-icon"/>
                </s:a>
            </td>
        </s:elseif>
        <s:elseif test="pageMode==7">
            <td class="center-align">
                <s:property value="dueDate"/>
            </td>
            <td class="center-align">
                <s:if test="status.ordinal()== 0">
                    <s:url id="initGenerateLatter" action="initGenerateLatter">
                        <s:param name="organizationId" value="id"/>
                    </s:url>
                    <s:a href="%{initGenerateLatter}">
                        <img src="<s:url value='/images/post_letter.png'/>" border="none" width="25"
                             height="25" title="Generate"/>
                    </s:a>
                    <%--register Letter--%>
                    <s:url id="registerLetter" action="loadLetterRegistrationPage">
                        <s:param name="moduleId" value="id"/>
                    </s:url>
                    <s:a href="%{registerLetter}">
                        <img src="<s:url value='/images/register-letter.jpg'/>" border="none" width="25"
                             height="25" title="Register"/>
                    </s:a>
                </s:if>
            </td>
            </tr>
        </s:elseif>
        <s:elseif test="pageMode==9">
            <td class="center-align">
                <s:url id="populateInitAddOrganization" action="populateInitAddOrganization">
                    <s:param name="organizationId" value="id"/>
                </s:url>
                <s:a href="%{populateInitAddOrganization}">
                    <img src="<s:url value='/images/icon_register.jpg'/>" border="none" class="image-icon" title="Add"/>
                </s:a>
            </td>
        </s:elseif>

    </s:iterator>
    </tbody>
</table>
<s:include value="../dataTableLocalizationLabels.jsp"/>